<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
           添加信息
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link href="__PUBLIC__/skin/nei.css" type="text/css" rel="stylesheet">
  </head>
</head>
<body onLoad="initPage()">
<div id="LoadingBar"><img src="__PUBLIC__/images/load.gif" /></div>
<div class="d_contaiter">
<form class="layui-form layui-form-pane" action="{:url('admin/group/edit')}" method="post" enctype="multipart/form-data" onsubmit="return checkkk();">
  <div class="layui-form-item">
    <label class="layui-form-label">角色名称</label>
    <div class="layui-input-block">
      <input type="text" name="name"  value="{$data.name}" lay-verify="required" autocomplete="off" placeholder="标题" class="layui-input" maxlength="30">
      <input type="hidden" name="id"  value="{$data.id}">
    </div>
  </div>
  {php}
      $rulesArr = json_decode($data['rules']);
      $menusArr = json_decode($data['menus']);
  {/php}
  
  
  <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">
          URL权限管理
      </label>
      <table  class="layui-table layui-input-block">
          <tbody>
          {volist name="ruleRes" id="item"}
              <tr>
                  
                  <td>
                      <input type="checkbox" name="rules[]"  lay-skin="primary"  value="{$item['id']}" lay-filter="father" title="{$item['name']}" {in name="$item.id" value="$rulesArr"} checked {/in}>
                  </td>
                  <td>
                      <div class="layui-input-block">
                        {if isset($item.children)}
                        {volist name="$item.children" id="v"}
                          <input name="rules[]" lay-skin="primary" type="checkbox" value="{$v['id']}" title="{$v['name']}"  {in name="$v.id" value="$rulesArr"} checked {/in}>
                          {/volist}
                        {/if}
                      </div>
                  </td>
              </tr>
           {/volist}    
          </tbody>
      </table>
  </div>
  <div class="layui-form-item" style="display: none">
    <label class="layui-form-label">发 布 人</label>
    <div class="layui-input-block">
      <input type="text" name="addname"  value="{:session('UserName')}" lay-verify="required" autocomplete="off" placeholder="请输入分类排序" class="layui-input" maxlength="30">
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">角色描述</label>
    <div class="layui-input-block">
      <textarea name="desc"  class="layui-textarea">{$data.desc}</textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <button class="layui-btn layui-btn-green" type="submit">提交保存</button>
  </div>
</form>
</div>
<script src="__PUBLIC__/js/jquery-1.10.2.min.js" type="application/javascript"></script>
<script src="__PUBLIC__/js/neijqtab.js" type="application/javascript"></script>
<script src="__PUBLIC__/js/xlayui/layui.js" charset="utf-8"></script>
<script>
function initPage(){
  var objLoading = document.getElementById("LoadingBar");
  if (objLoading != null){
    objLoading.style.display = "none";
    $(".d_contaiter").css("display","block");
  }
}
</script>
<script>
layui.use(['form'], function(){
  var form = layui.form(),layer = layui.layer;
  form.on('checkbox(father)', function(data){
      if(data.elem.checked){
          $(data.elem).parent().siblings('td').find('input').prop("checked", true);
          form.render(); 
      }else{
         $(data.elem).parent().siblings('td').find('input').prop("checked", false);
          form.render();  
      }
  });
});
</script>
</body>
</html>